import {EasyA} from "../../src/common/EasyA";

import {Log} from "../../src/util/Log";
import {EasyAEndInterceptor} from "../../src/extra/EasyAEndInterceptor";
import {UtilFile} from "../../src/util/UtilFile";
import {ReturnParamInterceptor} from "./webroot/ReturnParamInterceptor";
import {Util} from "../../src/util/Util";
import {SleepInterceptor} from "./webroot/SleepInterceptor";


const AA = new EasyA({
    setting:{
        port:2333,
        rootDir:UtilFile.getCurrentPath(__dirname+'/webroot'),
        staticDir:UtilFile.getCurrentPath(__dirname+'/static'),
        dev:true // 开发模式
    },

});
const app = AA.express;
AA.startRoute();

AA.addInterceptor(EasyAEndInterceptor);

AA.defaultModule.enableActionLog();
AA.defaultModule.enableParamResolve();
// var multer  = require('multer');
// var upload = multer({ dest: 'uploads/' });
// app.post('/profile', upload.any(), function (req, res, next) {
//     console.log(req);
//     res.send("OOOK");
// });


AA.defaultModule.enableI18n({
    resources:Util.readI18nResFromDir(UtilFile.getCurrentPath(__dirname+'/i18n'))
});

AA.addInterceptor(ReturnParamInterceptor);
AA.addInterceptor(SleepInterceptor);

AA.router.registerAllController();
AA.endRoute();

async function start(){
    await AA.start();
    Log.important("服务器开启")
}
start();

